package mianshi.bytedance;

import java.util.Scanner;

public class T1 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int M = sc.nextInt();
        int N = sc.nextInt();

        int[] array = new int[N];
        for(int i = 0 ; i < N ; i++ ) {
            array[i] = sc.nextInt();
        }
        // 先认为第一个最便宜
        int min = array[0];
        int ans = 0;
        for(int i = 1 ; i < N ; i++) {
            ans = ans + min;
            min = Math.min(min, array[i]);
        }

        for(int i = N ; N <= M ; N++ ) {
            ans = ans + min;
        }

        System.out.println(ans);
    }
}
